package com.shareach.domain;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shareach.domain.common.Entity;
import com.shareach.util.Globals;

/**
 * 卡惠数据
 * 
 * @author zuoshuaiok@gmail.com
 * 
 *         2013-1-28
 */
@Document(collection = "bizCard")
public class BizCardDomain extends Entity {
	// 优惠标题
	private String title;
	// 优惠说明
	private String descry;
	// 截止日期
	private Date end;
	// 图片
	private String img;
	// 城市[参见 城市BaseCity]
	private Long city;
	// 品牌名称
	private String brandName;
	// 分店名称
	private String name;
	// 采集名
	private String orgName;
	// 采集网址
	private String url;
	// 商家Id[没有绑定为空]
	private Long shopId;
	// 商家电话
	private String[] tels;
	// 银行
	private String site;
	// 唯一标识
	private String siteId;
	// 折扣[折扣率*100]
	private Integer discount;
	// 状态
	private Integer status;
	// 地址
	private String addr;
	// 匹配时间
	private Date matchTime;
	// 更新时间或者创建时间
	private Date updateTime = new Date();
	// 上架时间
	private Date deployTime;
	// 创建时间
	private Date creatTime;
	@Transient
	private BaseShopDomain baseShop;

	public BaseShopDomain getBaseShop() {
		return baseShop;
	}

	public void setBaseShop(BaseShopDomain baseShop) {
		this.baseShop = baseShop;
	}

	public Date getCreatTime() {
		return creatTime;
	}

	public void setCreatTime(Date creatTime) {
		this.creatTime = creatTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDeployTime() {
		return deployTime;
	}

	public void setDeployTime(Date deployTime) {
		this.deployTime = deployTime;
	}

	public Date getMatchTime() {
		return matchTime;
	}

	public void setMatchTime(Date matchTime) {
		this.matchTime = matchTime;
	}

	public String getAddr() {
		return addr;
	}

	public String getBrandName() {
		return brandName;
	}

	public String getDescry() {
		return descry;
	}

	public Integer getDiscount() {
		return discount;
	}

	public Date getEnd() {
		return end;
	}

	public String getImg() {
		return img;
	}

	public String getName() {
		return name;
	}

	public String getOrgName() {
		return orgName;
	}

	public Long getShopId() {
		return shopId;
	}

	public Integer getStatus() {
		return status;
	}

	public String[] getTels() {
		return tels;
	}

	public String getTitle() {
		return title;
	}

	public String getUrl() {
		return url;
	}

	public void setAddr(String addr) {
		this.addr = addr;
	}

	public void setBrandName(String brandName) {
		this.brandName = brandName;
	}

	public Long getCity() {
		return city;
	}

	public void setCity(Long city) {
		this.city = city;
	}

	public void setDescry(String descry) {
		this.descry = descry;
	}

	public void setDiscount(Integer discount) {
		this.discount = discount;
	}

	public void setEnd(Date end) {
		this.end = end;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getSite() {
		return site;
	}

	public void setSite(String site) {
		this.site = site;
	}

	public String getSiteId() {
		return siteId;
	}

	public void setSiteId(String siteId) {
		this.siteId = siteId;
	}

	public void setShopId(Long shopId) {
		this.shopId = shopId;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public void setTels(String[] tels) {
		this.tels = tels;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public BizCardDomain compareTo(BizCardDomain domain) {
		BizCardDomain change = new BizCardDomain();
		if (domain == null)
			return change;
		if (StringUtils.isNotEmpty(domain.getTitle())) {
			if (this.title == null || !this.title.trim().equals(domain.getTitle().trim())) {
				change.setTitle(domain.getTitle());
			}
		}
		if (StringUtils.isNotEmpty(domain.getDescry())) {
			if (this.descry == null || !this.descry.trim().equals(domain.getDescry())) {
				change.setDescry(domain.getDescry());
			}
		}
		if (domain.getEnd() != null) {
			if (this.end != null) {
				if (!Globals.FORMAT_TYPE_A.format(this.end).equals(Globals.FORMAT_TYPE_A.format(domain.getEnd()))) {
					change.setEnd(domain.getEnd());
				}
			} else {
				change.setEnd(domain.getEnd());
			}
		}
		if (StringUtils.isNotEmpty(domain.getImg())) {
			if (this.img == null || !this.img.trim().equals(domain.getImg().trim())) {
				change.setImg(domain.getImg().trim());
			}
		}
		if (StringUtils.isNotEmpty(domain.getOrgName())) {
			if (this.orgName == null || !this.orgName.trim().equals(domain.getOrgName().trim())) {
				change.setOrgName(domain.getOrgName().trim());
			}
		}
		if (StringUtils.isNotEmpty(domain.getUrl())) {
			if (this.url == null || !this.url.trim().equals(domain.getUrl().trim())) {
				change.setUrl(domain.getUrl().trim());
			}
		}
		if (domain.getDiscount() != null) {
			if (this.discount == null || !this.discount.equals(domain.getDiscount())) {
				change.setDiscount(domain.getDiscount());
			}
		}

		if (domain.getStatus() != null) {
			if (null == this.status || !this.status.equals(domain.getStatus())) {
				change.setStatus(domain.getStatus());
			}
		}
		return change;
	}
}
